package org.forever.learn.util;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import jdk.jfr.Description;
import lombok.Data;
import org.apache.tika.utils.StringUtils;
import org.springframework.stereotype.Component;

import java.util.function.Function;

@Description("帮助用户查询某天的天气情况")
public  class DayWeatherFunction implements Function<DayWeatherFunction.Request, DayWeatherFunction.Response> {
    @Override
    public Response apply(Request  request) {
        if(StringUtils.isEmpty(request.dateStr)){
            return new  DayWeatherFunction.Response("请输入您要 查询的日期 ");
        }
        return new DayWeatherFunction.Response(String.format("%s的天气是零上27摄氏度，局部有阵雨",request.dateStr));
    }

    public record Request( @JsonProperty(required = true)
                           @JsonPropertyDescription("用户输入的日期")
                           String dateStr){}


    public record Response(String dayWeather){}
}
